package com.huawei.appmarket.oobe.activity;

import android.app.ActionBar;
import android.app.Activity;
import android.graphics.Rect;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.ExpandableListView;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import androidx.annotation.RequiresApi;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.a;
import androidx.recyclerview.widget.RecyclerView.f;
import androidx.recyclerview.widget.RecyclerView.j;
import androidx.recyclerview.widget.RecyclerView.s;
import androidx.recyclerview.widget.RecyclerView.t;
import com.huawei.appgallery.horizontalcard.api.view.BounceHorizontalRecyclerView;
import com.huawei.appgallery.serverreqkit.api.bean.startup.StartupResponse$OOBEAppInfo;
import com.huawei.appmarket.R;
import com.huawei.appmarket.service.apppermission.bean.DownloadPermissionResponse.AppPermissionInfo;
import com.huawei.appmarket.service.apppermission.bean.SingleAppPermissionInfo;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import o.ayy;
import o.azb;
import o.dld;
import o.dlf;
import o.dlg;
import o.dli;
import o.dlj;
import o.Logger;
import o.ContentManager;
import o.eiy;
import o.epv;
import o.CollectCheck;
import o.eqx;
import o.MinimumFactory;

public class OOBEAppPermissionActivity extends Activity {
    private ArrayList<String> ʻ = new ArrayList();
    private dlj ʽ;
    private ArrayList<SingleAppPermissionInfo> ˊ = new ArrayList();
    private RelativeLayout ˋ;
    private View ˎ;
    private List<StartupResponse$OOBEAppInfo> ˏ;
    private dlf ॱ;
    private c ॱॱ;
    private List<StartupResponse$OOBEAppInfo> ᐝ;

    class c extends a<s> {
        final /* synthetic */ OOBEAppPermissionActivity ˋ;
        ArrayList<SingleAppPermissionInfo> ˏ;

        class b extends s {
            final /* synthetic */ c ॱˋ;
            private ImageView ᐝॱ;

            public b(c cVar, View view) {
                this.ॱˋ = cVar;
                super(view);
                this.ᐝॱ = (ImageView) view.findViewById(R.id.oobe_app_permission_icon);
            }
        }

        public c(OOBEAppPermissionActivity oOBEAppPermissionActivity, ArrayList<SingleAppPermissionInfo> arrayList) {
            this.ˋ = oOBEAppPermissionActivity;
            this.ˏ = arrayList;
        }

        public s ˎ(ViewGroup viewGroup, int i) {
            return new b(this, LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.oobe_listitem_permission_icon, viewGroup, false));
        }

        public void ॱ(s sVar, int i) {
            eqx.ˎ(((b) sVar).ᐝॱ, (String) this.ˋ.ʻ.get(i));
        }

        public int ˏ() {
            if (this.ˏ == null) {
                return 0;
            }
            return this.ˏ.size();
        }
    }

    class e extends f {
        final /* synthetic */ OOBEAppPermissionActivity ˊ;
        int ˎ;

        public e(OOBEAppPermissionActivity oOBEAppPermissionActivity, int i) {
            this.ˊ = oOBEAppPermissionActivity;
            this.ˎ = epv.ˋ(oOBEAppPermissionActivity, i);
        }

        public void ˏ(Rect rect, View view, RecyclerView recyclerView, t tVar) {
            super.ˏ(rect, view, recyclerView, tVar);
            rect.left = this.ˎ;
            if (recyclerView.ʼ(view) != 0) {
                return;
            }
            if (MinimumFactory.getBoolValue(ContentManager.getInstant().getContext())) {
                rect.right = 0;
            } else {
                rect.left = 0;
            }
        }
    }

    @RequiresApi(api = 23)
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        ayy.ˋ().ˎ(getWindow());
        Logger.ˎ("OOBE", "OOBEAppPermissionActivity onCreate");
        ˋ(getResources().getString(R.string.oobe_app_gallery_title));
        ˎ();
        ˋ();
    }

    @RequiresApi(api = 23)
    protected void onResume() {
        super.onResume();
        if (dli.ˏ(this)) {
            View decorView = getWindow().getDecorView();
            decorView.setSystemUiVisibility(decorView.getSystemUiVisibility() | 4098);
        }
    }

    private void ˋ() {
        this.ᐝ = dld.ˎ().ᐝ();
        if (CollectCheck.isEmpty(this.ᐝ)) {
            Logger.ˎ("OOBE", "OOBEAppPermissionActivity:SelectedData is empty");
            finish();
            return;
        }
        List ॱ = dld.ˎ().ॱ();
        if (CollectCheck.isEmpty(ॱ)) {
            Logger.ˎ("OOBE", "OOBEAppPermissionActivity:UnsortedAppPermissions in OOBEData is empty");
            this.ˏ = dld.ˎ().ˋ();
            ˏ();
            dlg.ˊ(this.ˏ, new o.dlg.e(this) {
                final /* synthetic */ OOBEAppPermissionActivity ॱ;

                {
                    this.ॱ = r1;
                }

                public void ˎ() {
                    this.ॱ.ˊ();
                }

                public void ˋ(int i) {
                    this.ॱ.ॱ.ˋ();
                }
            });
            return;
        }
        ॱ(ॱ);
    }

    protected void ˋ(String str) {
        ActionBar actionBar = getActionBar();
        if (actionBar != null) {
            actionBar.setTitle(str);
            actionBar.setHomeButtonEnabled(true);
            actionBar.setDisplayHomeAsUpEnabled(true);
        }
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        switch (menuItem.getItemId()) {
            case 16908332:
                finish();
                return false;
            default:
                return super.onOptionsItemSelected(menuItem);
        }
    }

    public void ˎ() {
        setContentView(R.layout.oobe_activity_oobe_app_permission);
        this.ˋ = (RelativeLayout) findViewById(R.id.oobe_app_permission_layout);
        azb.ॱ(this.ˋ, R.id.oobe_app_permission_tips);
        this.ˎ = (RelativeLayout) findViewById(R.id.oobe_no_permission_layout);
        azb.ॱ(this.ˎ, R.id.oobe_no_permission_tips);
        ExpandableListView expandableListView = (ExpandableListView) findViewById(R.id.oobe_app_permission_text_listview);
        this.ʽ = new dlj(this, this.ˊ);
        expandableListView.setAdapter(this.ʽ);
        BounceHorizontalRecyclerView bounceHorizontalRecyclerView = (BounceHorizontalRecyclerView) findViewById(R.id.oobe_app_permission_icon_horizontal_recycler_view);
        azb.ˋ(bounceHorizontalRecyclerView);
        this.ॱॱ = new c(this, this.ˊ);
        j linearLayoutManager = new LinearLayoutManager(this, 0, false);
        bounceHorizontalRecyclerView.setLayoutManager(linearLayoutManager);
        bounceHorizontalRecyclerView.ॱ(new e(this, 12));
        if (MinimumFactory.getBoolValue(ContentManager.getInstant().getContext())) {
            bounceHorizontalRecyclerView.setLayoutDirection(0);
            linearLayoutManager.ˊ(true);
        }
        bounceHorizontalRecyclerView.setAdapter(this.ॱॱ);
        new eiy().ˏ(bounceHorizontalRecyclerView);
    }

    private void ˏ() {
        this.ˋ.setVisibility(4);
        this.ˎ.setVisibility(8);
        if (this.ॱ == null) {
            this.ॱ = new dlf();
            this.ॱ.ˏ(findViewById(R.id.oobe_permission_loadingPager));
            this.ॱ.ˏ(new OnClickListener(this) {
                final /* synthetic */ OOBEAppPermissionActivity ˏ;

                {
                    this.ˏ = r1;
                }

                public void onClick(View view) {
                    dlg.ˊ(this.ˏ.ˏ, new o.dlg.e(this) {
                        final /* synthetic */ AnonymousClass1 ˏ;

                        {
                            this.ˏ = r1;
                        }

                        public void ˎ() {
                            this.ˏ.ˏ.ˊ();
                        }

                        public void ˋ(int i) {
                            this.ˏ.ˏ.ॱ.ˋ();
                        }
                    });
                }
            });
            this.ॱ.ˋ(new OnClickListener(this) {
                final /* synthetic */ OOBEAppPermissionActivity ˏ;

                {
                    this.ˏ = r1;
                }

                public void onClick(View view) {
                    this.ˏ.finish();
                }
            });
        }
        this.ॱ.ॱ(0);
    }

    private void ˊ() {
        if (this.ॱ != null) {
            this.ॱ.ॱ(8);
            this.ॱ = null;
        }
        ॱ(dld.ˎ().ॱ());
    }

    private void ॱ(List<AppPermissionInfo> list) {
        Object ˎ = dlg.ˎ(list, this.ᐝ);
        if (CollectCheck.isEmpty(ˎ)) {
            this.ˋ.setVisibility(4);
            this.ˎ.setVisibility(0);
            Logger.ˎ("OOBE", "OOBEAppPermissionActivity:sortedAppPermissions is empty");
            return;
        }
        this.ˊ.clear();
        Iterator it = ˎ.iterator();
        while (it.hasNext()) {
            SingleAppPermissionInfo singleAppPermissionInfo = (SingleAppPermissionInfo) it.next();
            for (StartupResponse$OOBEAppInfo startupResponse$OOBEAppInfo : this.ᐝ) {
                if (singleAppPermissionInfo.ˊ().equals(startupResponse$OOBEAppInfo.ˎ())) {
                    this.ʻ.add(startupResponse$OOBEAppInfo.ʼ());
                    this.ˊ.add(singleAppPermissionInfo);
                }
            }
        }
        if (this.ˋ == null) {
            return;
        }
        if (CollectCheck.isEmpty(this.ˊ)) {
            this.ˋ.setVisibility(4);
            this.ˎ.setVisibility(0);
            return;
        }
        this.ˎ.setVisibility(8);
        this.ˋ.setVisibility(0);
    }
}
